<?php
/**
 * This is the shortcut to Yii::app()
 * @return CWebApplication
 */
function app()
{
    return Yii::app();
}

/**
 * This is the shortcut to Yii::app()->createUrl()
  */
function url($route, $params=array())
{
	return Yii::app()->createUrl($route, $params);
}

/**
 * This is the shortcut to Yii::app()->getController()->createAbsoluteUrl()
 */
function aUrl($route,$params=array(),$schema='',$ampersand='&')
{
    return Yii::app()->getController()->createAbsoluteUrl($route,$params,$schema,$ampersand);
}


function mkdirs($dir, $mode = 0777)
{
	return is_dir($dir) or (mkdirs(dirname($dir)) and mkdir($dir, $mode));
}


function create_uuid($withSep = false)
{
	$str = md5(uniqid(mt_rand(), true));
	$uuid  = substr($str,0,8) . ($withSep? '-' : '');
	$uuid .= substr($str,8,4) . ($withSep? '-' : '');
	$uuid .= substr($str,12,4) . ($withSep? '-' : '');
	$uuid .= substr($str,16,4) . ($withSep? '-' : '');
	$uuid .= substr($str,20,12);
	return $uuid;
}



define('ROOT_DIR', dirname(__FILE__) . '/');